{% extends "base.html" %}

{% block css%}
<link href="/assets/js/highlightjs/default.min.css" rel="stylesheet" type="text/css">
{% endblock %}

{% block title %}
{{topic.title|uw}}
{% endblock %}

{% block content %}

<div id="article">
    <h1>{{topic.title|uw}}</h1>
    {%if topic.pass|not_null && !base.login %}
    <div class="text">
        <p style="color:red;">这是一篇密码日志！</p>
        <p>
        <form action="/topic/pass" method="post" onsubmit="return ckpass('{{topic.id|uw}}');">
            <input type="hidden" name="id" value="{{topic.id|uw}}">
            <input placeholder="请输入密码..." name="pass" type="password" value="" id="password" class="search-text">
            <button class="search-submit" type="submit">确认</button>
        </form>
        </p>
    </div>
    {%else%}
    <div class="text">
            {% if topic.style|is && topic.style|uw==1 %}
            {{topic.content|uw|markdown}}
            {%else%}
            {{topic.content|uw|safe}}
            {%endif%}
    </div>
    {%endif%}
    <p class="time clb">{{topic.atime|uw|dt}}</p>
    <p class="navPost">
        <a href="JavaScript:history.back();">返回</a>&nbsp;
        <a href="JavaScript:DotRoll('pl')">我要评论</a>
        {% if base.login%}
        <a id="zd-{{topic.id|uw}}" href="javascript:void(0)" ist="{{topic.ist|uw}}"
            onclick="zdlog('{{topic.id|uw}}',1)">{%if topic.ist|uw == 0 %}置顶{%else%}取消{%endif%}</a>&nbsp;
        <a href="/post?id={{topic.id|uw}}" title="编辑博客">编辑</a>&nbsp;
        <a href="javascript:void(0)" onclick="dellog('{{topic.id|uw}}','1')">删除</a>
        {%endif%}
    </p>
</div>
<div id="articlenav">
    {%if pre|is%}
    {% let pre=pre|uw%}
    <a class="pre" href="/topic/get?id={{pre.id|uw}}">{{pre.title|uw}}</a>
    {%endif%}
    {%if next|is%}
    {% let next=next|uw%}
    <a class="next" href="/topic/get?id={{next.id|uw}}">{{next.title|uw}}</a>
    {%endif%}
</div>
<div id="comments">
    <h3>{%if topic.lock|uw == 1 %}评论已关闭{%else%}共有{{topic.num|uw}}条评论！{%endif%}</h3>
    <ol class="comment_list">
        {% for item in reply %}
        <li class="comlist" id="Com-{{item.id|uw}}">
            <div id="Ctext-{{item.id|uw}}" class="comment">
                <div class="comment_meta">
                    <cite>{{item.pname|uw}}</cite> <span class="time">{{item.ptime|uw|dt}}</span>
                    {% if base.login%}
                    <span class="reply">
                        <!-- <em>1#</em> -->
                        <a href="javascript:void(0)" onclick="repl('{{item.id|uw}}')" title="回复评论">回复</a>&nbsp;
                        <a href="javascript:void(0)" onclick="delpl('{{item.id|uw}}','{{item.cid|uw}}')"
                            class="item">删除</a>&nbsp;
                        {%if item.isn|uw == 1 %}
                        <a href="javascript:void(0)" id="sh-{{item.id|uw}}" onclick="shpl('{{item.id|uw}}')"
                            class="item">审核</a>
                        {%endif%}
                    </span>
                    {%endif%}
                </div>
                <p>{%if item.isn|uw == 1 && !base.login %}评论审核中{%else%}{{item.pcontent|uw}}{%endif%}</p>
                {%if item.rcontent|is%}
                <p class="re">&nbsp;&nbsp;<strong style="color:#C00">回复</strong>：<span>{{item.rcontent|uw}}</span>
                </p>
                {%endif%}
            </div>
        </li>
        {% endfor %}
    </ol>
    {%if topic.lock|uw == 0 %}
    <div id="respond" class="comment-respond">
        <h3 id="reply-title" class="comment-reply-title">发表评论</h3>
        <a name="pl"></a>
        <div class="s_e mt10">
            <input name="pname" tabindex="1" placeholder="您的昵称" id="pname" type="text" class="input_narrow" value="{{username|uw}}"
                maxlength="10">
        </div>
        <div class="s_e">
            <textarea tabindex="2" placeholder="发言要文明，评论有水平..." name="pcontent" rows="3" id="pcontent"
                class="input_textarea"></textarea>
        </div>
        <div class="s_e">
            <button name="add" onclick="addpl('{{topic.id|uw}}')" id="add" class="btn"> 提 交 </button>
            <button name="bck" onclick="history.back();" id="bck" class="btn"> 返 回 </button>
            <span id="errmsg"></span>
        </div>
    </div>
    {%endif%}
</div>
{%if rid|is%}
<script type="text/javascript" language="javascript">
    location.href = "/topic/get?id={{topic.id|uw}}#Com-{{rid|uw}}";
</script>
{%endif%}
{% endblock %}